﻿/********
* 
* 
*  Description:
*  Create By Kain at 4/2/2011 2:59:08 PM
*  
*
*  Revision History:
*  Date                  Who                 What
*  
* 
*/

#region

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#endregion

namespace Cherry.Agile.ServiceModel.Runtime
{
    [Serializable]
    public abstract class ServiceFilter:IServiceFilter
    {
        
        public static ServiceFilter Empty = new EmptyFilter();
    
        public bool IsEmpty
        {
            get { return this is ServiceFilter.EmptyFilter; }
        }

        
        public virtual bool Pass(IService test)
        {
            return Match(test);
        }
                 
        public abstract bool Match(IService test);
                
        [Serializable]
        private class EmptyFilter : ServiceFilter
        {
            public override bool Match(IService test)
            {
                return true;
            }

            public override bool Pass(IService test)
            {
                return true;
            }
        }
    }
}
